package com.goodfather.textbook.youdao.pad.bean;

import android.os.Parcel;
import android.os.Parcelable;

import com.google.gson.annotations.SerializedName;

import java.util.List;

/**
 * Created by geyihao on 17/2/7.
 */
public class Production implements Parcelable {

    /**
     * 在列表中是否选中
     */
    @SerializedName("default")
    private boolean check;

    @SerializedName("id")
    private String id;

    @SerializedName("productionId")
    private int productionId;

    @SerializedName("publishingId")
    private String publishingId;

    @SerializedName("firstPrice")
    private double firstPrice;

    @SerializedName("minPrice")
    private double minPrice;

    @SerializedName("originalPrice")
    private double originalPrice;

    /**
     * 积分汇率：rmb = 总积分 /  pointRate
     */
    @SerializedName("pointRate")
    private int pointRate;

    /**
     * 抵扣的积分数量
     */
    private int deductionPoint;

    /**
     * 积分抵扣后的价格
     * {@link Production#realPrice} =
     *      {@link Production#firstPrice} - {@link Production#deductionPoint} / {@link Production#pointRate}
     */
    private double realPrice;

    /**
     * 第三方价格（用户输入的价格）
     */
    private double thirdFee;

    @SerializedName("isFree")
    private boolean isFree;

    @SerializedName("payPoint")
    private boolean payPoint;

    @SerializedName("name")
    private String name;

    @SerializedName("productionTypeId")
    private int productionTypeId;

    @SerializedName("totalPoint")
    private int totalPoint;

    /**
     * 有效期：若为null则永久有效，否则显示有效期天数[例如180天]
     */
    @SerializedName("validityDays")
    private Integer validityDays;

    @SerializedName("coverImage")
    private String coverImage;

    @SerializedName("productionImage")
    private String productionImage;

    @SerializedName("description")
    private String description;

    @SerializedName("count")
    private int count;

    //商品合集
    @Deprecated
    @SerializedName("bookCollectionId")
    private int bookCollectionId;

    @Deprecated
    @SerializedName("bookList")
    private List<BookListBean> bookList;

    @Deprecated
    @SerializedName("hint")
    private String hint;

    public Production() {
    }


    protected Production(Parcel in) {
        check = in.readByte() != 0;
        id = in.readString();
        productionId = in.readInt();
        publishingId = in.readString();
        firstPrice = in.readDouble();
        minPrice = in.readDouble();
        originalPrice = in.readDouble();
        pointRate = in.readInt();
        deductionPoint = in.readInt();
        realPrice = in.readDouble();
        thirdFee = in.readDouble();
        isFree = in.readByte() != 0;
        payPoint = in.readByte() != 0;
        name = in.readString();
        productionTypeId = in.readInt();
        totalPoint = in.readInt();
        coverImage = in.readString();
        productionImage = in.readString();
        bookCollectionId = in.readInt();
        bookList = in.createTypedArrayList(BookListBean.CREATOR);
        hint = in.readString();
    }

    public static final Creator<Production> CREATOR = new Creator<Production>() {
        @Override
        public Production createFromParcel(Parcel in) {
            return new Production(in);
        }

        @Override
        public Production[] newArray(int size) {
            return new Production[size];
        }
    };



    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public int getCount() {
        return count;
    }

    public void setCount(int count) {
        this.count = count;
    }

    public String getProductionImage() {
        return productionImage;
    }

    public void setProductionImage(String productionImage) {
        this.productionImage = productionImage;
    }

    public String getHint() {
        return hint;
    }

    public void setHint(String hint) {
        this.hint = hint;
    }

    public double getThirdFee() {
        return thirdFee;
    }

    public void setThirdFee(double thirdFee) {
        this.thirdFee = thirdFee;
    }

    public double getRealPrice() {
        return realPrice;
    }

    public void setRealPrice(double realPrice) {
        this.realPrice = realPrice;
    }

    public int getDeductionPoint() {
        return deductionPoint;
    }

    public void setDeductionPoint(int deductionPoint) {
        this.deductionPoint = deductionPoint;
    }

    public double getMinPrice() {
        return minPrice;
    }

    public void setMinPrice(double minPrice) {
        this.minPrice = minPrice;
    }

    public boolean isCheck() {
        return check;
    }

    public void setCheck(boolean check) {
        this.check = check;
    }

    public String getCoverImage() {
        return coverImage;
    }

    public void setCoverImage(String coverImage) {
        this.coverImage = coverImage;
    }

    public Integer getValidityDays() {
        return validityDays;
    }

    public void setValidityDays(Integer validityDays) {
        this.validityDays = validityDays;
    }

    public boolean isFree() {
        return isFree;
    }

    public void setFree(boolean free) {
        isFree = free;
    }

    public int getProductionTypeId() {
        return productionTypeId;
    }

    public void setProductionTypeId(int productionTypeId) {
        this.productionTypeId = productionTypeId;
    }

    public int getProductionId() {
        return productionId;
    }

    public void setProductionId(int productionId) {
        this.productionId = productionId;
    }


    public double getFirstPrice() {
        return firstPrice;
    }

    public void setFirstPrice(double firstPrice) {
        this.firstPrice = firstPrice;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getPublishingId() {
        return publishingId;
    }

    public void setPublishingId(String publishingId) {
        this.publishingId = publishingId;
    }

    public double getOriginalPrice() {
        return originalPrice;
    }

    public void setOriginalPrice(double originalPrice) {
        this.originalPrice = originalPrice;
    }

    public boolean isPayPoint() {
        return payPoint;
    }

    public void setPayPoint(boolean payPoint) {
        this.payPoint = payPoint;
    }

    public int getTotalPoint() {
        return totalPoint;
    }

    public void setTotalPoint(int totalPoint) {
        this.totalPoint = totalPoint;
    }

    public int getBookCollectionId() {
        return bookCollectionId;
    }

    public void setBookCollectionId(int bookCollectionId) {
        this.bookCollectionId = bookCollectionId;
    }

    public List<BookListBean> getBookList() {
        return bookList;
    }

    public void setBookList(List<BookListBean> bookList) {
        this.bookList = bookList;
    }

    public int getPointRate() {
        return pointRate;
    }

    public void setPointRate(int pointRate) {
        this.pointRate = pointRate;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeByte((byte) (check ? 1 : 0));
        dest.writeString(id);
        dest.writeInt(productionId);
        dest.writeString(publishingId);
        dest.writeDouble(firstPrice);
        dest.writeDouble(minPrice);
        dest.writeDouble(originalPrice);
        dest.writeInt(pointRate);
        dest.writeInt(deductionPoint);
        dest.writeDouble(realPrice);
        dest.writeDouble(thirdFee);
        dest.writeByte((byte) (isFree ? 1 : 0));
        dest.writeByte((byte) (payPoint ? 1 : 0));
        dest.writeString(name);
        dest.writeInt(productionTypeId);
        dest.writeInt(totalPoint);
        dest.writeString(coverImage);
        dest.writeString(productionImage);
        dest.writeInt(bookCollectionId);
        dest.writeTypedList(bookList);
        dest.writeString(hint);
    }


    /**
     * 合集书本列表
     */
    @Deprecated
    public static class BookListBean implements Parcelable {

        @SerializedName("bookId")
        private String bookId;
        @SerializedName("publishingId")
        private String publishingId;

        @SerializedName("bookName")
        private String bookName;

        protected BookListBean(Parcel in) {
            bookId = in.readString();
            publishingId = in.readString();
            bookName = in.readString();
        }

        public static final Creator<BookListBean> CREATOR = new Creator<BookListBean>() {
            @Override
            public BookListBean createFromParcel(Parcel in) {
                return new BookListBean(in);
            }

            @Override
            public BookListBean[] newArray(int size) {
                return new BookListBean[size];
            }
        };

        public String getBookId() {
            return bookId;
        }

        public void setBookId(String bookId) {
            this.bookId = bookId;
        }

        public String getPublishingId() {
            return publishingId;
        }

        public void setPublishingId(String publishingId) {
            this.publishingId = publishingId;
        }

        public String getBookName() {
            return bookName;
        }

        public void setBookName(String bookName) {
            this.bookName = bookName;
        }

        @Override
        public int describeContents() {
            return 0;
        }

        @Override
        public void writeToParcel(Parcel dest, int flags) {
            dest.writeString(bookId);
            dest.writeString(publishingId);
            dest.writeString(bookName);
        }
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Production that = (Production) o;

        return productionId == that.productionId;

    }

    @Override
    public int hashCode() {
        return productionId;
    }
}
